package com.sinosoft.dsp.component.bpm.viewbean.searchdata;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.model.SelectItem;

import org.jbpm.api.ProcessDefinition;

import com.sinosoft.dsp.component.bpm.facade.engine.ProcessResourceFacade;
import com.sinosoft.dsp.component.bpm.util.JbpmTaskStateType;
import com.sinosoft.dsp.platform.components.ViewListBean;
import com.sinosoft.dsp.platform.utils.SinoManagedBean;

public class BpmInstanceSearchViewBean extends ViewListBean implements
		IBpmInstanceSearchViewBean {

	private static final long serialVersionUID = -7015850407017249201L;

	// 流程实例ID
	private String instanceId;

	// 处理状态
	private String dealType;

	// 流程类型
	private String defineType;

	// 流程任务节点类型
	private String defineTaskNode;

	// 文书类型
	private String documentType;

	// 创建者
	private String creatorId;

	// 创建时间
	private Date createTimeFrom;

	private Date createTimeTo;

	// 办理人
	private String dealUserId;

	public String getInstanceId() {
		return instanceId;
	}

	public void setInstanceId(String instanceId) {
		this.instanceId = instanceId;
	}

	public String getDealType() {
		return dealType;
	}

	public void setDealType(String dealType) {
		this.dealType = dealType;
	}

	public List<SelectItem> getDealTypeItems() {
		return JbpmTaskStateType.getTaskStateItems();
	}

	public String getDefineType() {
		return defineType;
	}

	public void setDefineType(String defineType) {
		this.defineType = defineType;
	}

	public List<SelectItem> getDefineTypeItems() {
		ProcessResourceFacade prf = SinoManagedBean
				.findBean("processResourceFacade");
		List<ProcessDefinition> pds = prf
				.queryLatestActiveProcessDefinitionAuto();

		List<SelectItem> list = new ArrayList<SelectItem>();

		if (pds != null && pds.size() > 0) {
			for (ProcessDefinition pd : pds) {
				list.add(new SelectItem(pd.getId(), pd.getName()));
			}
		}
		return list;
	}

	public String getDefineTaskNode() {
		return defineTaskNode;
	}

	public void setDefineTaskNode(String defineTaskNode) {
		this.defineTaskNode = defineTaskNode;
	}

	public List<SelectItem> getDefineTaskNodeItems() {
		List<SelectItem> list = new ArrayList<SelectItem>();
		// TODO
		return list;
	}

	public String getDocumentType() {
		return documentType;
	}

	public void setDocumentType(String documentType) {
		this.documentType = documentType;
	}

	public String getCreatorId() {
		return creatorId;
	}

	public void setCreatorId(String creatorId) {
		this.creatorId = creatorId;
	}

	public Date getCreateTimeFrom() {
		return createTimeFrom;
	}

	public void setCreateTimeFrom(Date createTimeFrom) {
		this.createTimeFrom = createTimeFrom;
	}

	public Date getCreateTimeTo() {
		return createTimeTo;
	}

	public void setCreateTimeTo(Date createTimeTo) {
		this.createTimeTo = createTimeTo;
	}

	public String getDealUserId() {
		return dealUserId;
	}

	public void setDealUserId(String dealUserId) {
		this.dealUserId = dealUserId;
	}

}
